<?php
/**
 * --------------------------------------------------------------------
 * MCore框架
 * 作者：阿枫，QQ：52037872，Email：nczy520@gmail.com
 * --------------------------------------------------------------------
 *
 * SVN revision information:
 * @version $Revision: 50 $:
 * @author  $Author: zy $:
 * @date      $Date: 2013-11-09 19:34:15 +0800 (星期六, 09 十一月 2013) $:
 * @url         $HeadURL: svn://vps.mdeve.com/web_mcore/manage/function/global.func.php $:
 */

define("IS_MANAGE", true);
global $_M, $m, $a, $args, $f, $flag;

chdir("../");
require 'core/runtime.php';

$m = $_GET["m"] ?? "index";
$a = $_GET["a"] ?? "main";
if(!strlen($m) || !strlen($a)) exit("Parameter error");

if($_M->cfg["module_enable"]) module_insert_code('manage_index_start');

// 初始化模块
$_M->db();
$_M->cache();
$_M->user();


if(!$_M->is_login && !($m == "login" && $a == "submit")) {
    // 未登陆，跳到登陆界面
    $m = "login";
    $a = "welcome";
}

require_once MANAGE_PATH. "/global.func.php";
_initialization();

$f = dirname(__FILE__). "/module/". strtolower($m). ".module.php";
if($_M->cfg["module_enable"]) module_insert_code('manage_index_proc');

if(file_exists($f)){
	require $f;
	if($a == "list") $a = "_list";
	$mod = "_". ucfirst($m)."Class";
	$module = new $mod();
	if(!method_exists($module, $a)) $a = "_". $a;
    logs_write($m, $a, $args);
	$module->$a();
}else{
	halt("Module {$m} not found!");
}

if($_M->cfg["module_enable"]) module_insert_code('manage_index_end');